function loadImg(src) {
  let promise = new Promise(function (resolve, reject) {
    const img = document.createElement("img");
    img.onload = () => {
      resolve(img);
    };
    img.onerror = () => {
      const err = new Error(`图片加载失败 ${src}`);
      reject(err);
    };
    img.src = src
  });
  return promise;
}

let src = "https://img.mukewang.com/szimg/5fc07b8509a05b3105400304";

let result = loadImg(src);

result
  .then(function (img) {
    alert(`width: ${img.width}`);
    return img;
  })
  .then(function (img) {
    alert(`height: ${img.height}`);
  })
  .catch(function (error) {
    alert(error);
  });
